﻿use sms
go
if exists(select name from sysobjects where name ='cp_query_sending' and type = 'P')
drop procedure cp_query_sending
go  
--查找所有正在发送的信息
create procedure cp_query_sending
as
--return dataset
if((select COUNT(*) from [Message]  where [State] & 0xf0 = 0x10) != 0)
	begin
		select * from [Message]  where [State] & 0xf0 = 0x10 order by Priority
	end
else
	begin
		--没有记录时返回空集合
		select * from [Message]  where [State] = -1
	end
go
